﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }



        private void button1_Click(object sender, EventArgs e)
        {
            var name = textBox1.Text;
            var pwd = textBox2.Text;

            string sql = string.Format("select * from Users where Username='{0}' and Password='{1}'", name, pwd);
            DataTable mytable = DBHelper.Select(sql);
            var myrow = mytable.Rows.Count;
            if (myrow == 1)
            {
                MessageBox.Show("登入成功");
                this.Hide();
                Form3 form3 = new Form3();
                form3.Show();
            }
            else
            {
                MessageBox.Show("登入失败");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
            form2.Show();
        }
    }
}
